package com.topInterview;

/**
 * @Author: huangzhigao
 * @Date: 2022/2/23 21:58
 */
public class leecode_283moveZero {
    public void moveZeroes(int[] nums) {
        int left = -1;
        int right = 0;
        while (right < nums.length) {
            if (nums[right] != 0) {
                swap(nums, ++left, right++);
            } else {
                right++;
            }
        }
    }


    public void swap(int[] nums, int a, int b) {
        int tmp = nums[a];
        nums[a] = nums[b];
        nums[b] = tmp;
    }
}
